home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / comp / icm-comp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  1.5 KB  |  54 lines

  1. /*
  2.                          I C M - C O M P . C
  3. */
  4.  
  5. #define LIBREQUEST
  6.  
  7. #include "iccomp.h"
  8.  
  9. #pragma comment(lib, "icmcomp")
  10. #pragma comment(lib, "../rss/icrss")
  11.  
  12. int main (argc, argv)            /* icm-comp source(txt) dest(bin) */
  13.     int
  14.         argc;
  15.     char
  16.         **argv;
  17. {
  18.     if (argc != 3)
  19.     {
  20.         copyright("Make Optimizing Compiler", version, release, 1);
  21.         error("Usage: %s source dest\n"
  22.               "where:\n"
  23.               "\tsource: source file to compile\n"
  24.               "\t        (normally output from ICM-PP)\n"
  25.               "\tdest:   name of binary file to generate\n"
  26.               ,
  27.               program_name(argv[0]));
  28.     }
  29.  
  30.     if
  31.     (
  32.         !(yyin = fopen(argv[1], "rt"))     /* open text file for parsing */
  33.         ||
  34.         !(s_bin = fopen(argv[2], "w+b"))   /* open binary file to write/read */
  35.     )
  36.         error("%s Can't read/write file(s)");
  37.  
  38.                                             /* malloc the dead-stack */
  39.     dead = xrealloc(NULL, sizeof(unsigned));
  40.  
  41.     stringbuf = xstrdup(nullstring);        /* malloc initial stringbuf */
  42.  
  43.                                             /* go to first codebyte pos */
  44.     fseek(s_bin, sizeof(BIN_HEADER_), SEEK_SET);
  45.  
  46.     yyparse();                              /* parse the source */
  47.  
  48.     if (!yynerr)                            /* backend if no errors */
  49.         backend();
  50.     else                                    /* informative message */
  51.         printf("\n%d error(s) detected\n", errcount);
  52.  
  53.     return(yynerr != 0);                    /* returnvalue */
  54. }